int [] x={100,200};
int [] y={200,95};
/*
int [] x={100,200};
int [] y={100,200};
*/


PImage MapImage;
PFont labelFont;
PImage[] AirplainImg;


// HND(TOKYO)    505,390
// FKU(FUKUOKA)  82,506  
// KMQ(KOMATSU)  367,342
// HIJ(HIROSIMA)  174,464






void setup()
{
  
  size(480,480);
  labelFont=createFont("SansSerif", 20);
  textFont(labelFont);
  ellipseMode(CENTER);
  for (int i = 0 ; i < 2 ; i++){
    stroke(0);
    fill (255);
    ellipse(x[i],y[i],2,2);
    stroke(255,0,0);
    fill(255,0,0,20);
    ellipse(x[i],y[i],10,10);
  }

  AirplainImg = new PImage[2];
  AirplainImg[0] = loadImage("p001.gif");
  AirplainImg[1] = loadImage("p002.gif");
  
  
}
void draw()
{
  int midx,midy;
  int lenx,leny;
  float lenc;
  float lenrad;
  float ang;

  background(128);
  smooth();
//  if ( flame == 0 ) {
        // get center point
    if (x[0]>x[1])  {
      lenx = x[0]-x[1];
      midx = (lenx)/2+x[1];
    } else {
      lenx = x[1]-x[0];
      midx = (lenx)/2+x[0];
    }
    if (y[0]>y[1])  {
      leny = y[0] - y[1];
      midy = (leny)/2 + y[1];
    } else {
      leny = y[1] - y[0];
      midy = (leny)/2 + y[0];
    }
    
    
    // plot center (for debug)
    strokeWeight(1);
    fill(0);
    stroke (0);
    ellipse (midx,midy,3,3);
    
    // get length 
    lenc = sqrt(pow(lenx,2) + pow(leny,2));
    
    // get angle
    ang = atan2(y[1]-y[0], x[1]-x[0]);
  
    // get radious (半径)
    lenrad = lenc/2;
  
 // }

  noFill();
  translate(midx,midy);
  rotate(ang);
  strokeWeight(4);
  if (frameCount % 96 == 0) {
    stroke (0,0,0);
    arc( 0, 0 , lenc, lenc , 0, PI);
  } else {
    stroke ( 255,255,255,50);
  }
  arc( 0, 0 , lenc, lenc , 0, PI*(frameCount % 96)/96);
  
  // new x = x * cos() - y * sin ()
  // new y = x * sin()  + y * cos()
  translate ( - AirplainImg[0].width/2 , - AirplainImg[0].height/2 );
  image(AirplainImg[0], lenc/2 * cos(PI*(frameCount % 96)/96), lenc/2 * sin(PI*(frameCount % 96)/96));

}
